<template>
  <div class="bg-white p-3 rounded-lg shadow">
    <div class="mb-2">
      <div class="flex justify-between text-sm text-gray-600 mb-1">
        <span>处理进度</span>
        <span>{{ Math.round(store.progressValue) }}%</span>
      </div>
      <div class="w-full bg-gray-200 rounded-full h-2.5">
        <div class="bg-blue-600 h-2.5 rounded-full" :style="{ width: `${store.progressValue}%` }"></div>
      </div>
    </div>
    
    <div class="text-sm">
      <p>当前时间: {{ formatTime(store.currentTime) }}</p>
      <p class="mt-1">{{ store.statusMessage }}</p>
    </div>
  </div>
</template>

<script setup>
import { useVideoStore } from '../stores/videoStore';

// 使用 Pinia store
const store = useVideoStore();

// 格式化时间
const formatTime = (seconds) => {
  if (isNaN(seconds)) return '00:00.00';
  
  const min = Math.floor(seconds / 60);
  const sec = Math.floor(seconds % 60);
  const ms = Math.floor((seconds % 1) * 100);
  
  return `${min.toString().padStart(2, '0')}:${sec.toString().padStart(2, '0')}.${ms.toString().padStart(2, '0')}`;
};
</script>

<script>
export default {
  name: 'ProgressDisplay',
  props: {
    progressValue: {
      type: Number,
      default: 0
    },
    currentTime: {
      type: Number,
      default: 0
    },
    statusMessage: {
      type: String,
      default: ''
    }
  }
}
</script>